/**
 * author:dengqinlong
 * qq:82093897
 */
Namespace.register("cjyjs.effect");

/*
 * @param {Object} P{obj,prop,startValue,endValue,units,jsEx}
 * @return {TypeName} 
 */
cjyjs.effect.changeProperties=function(P){
	if(!P.hasOwnProperty("obj")||!P.hasOwnProperty("prop")||!P.hasOwnProperty("startValue")||!P.hasOwnProperty("endValue"))return;
	P.obj=$(P.obj);
	if(!P.hasOwnProperty("units"))P.units="";
	
	var diff=P.endValue-P.startValue;
	var pEx="P.obj."+P.prop;
	var cValue=parseInt(eval(pEx));
	var newValue;
	if(diff==0)return;
		else if(diff<0){
				newValue=cValue-10;
				if(newValue<=P.endValue)newValue=P.endValue;
			}
			else {
				newValue=cValue+10;
				if(newValue>=P.endValue)newValue=P.endValue;
			}
	eval(pEx+'="'+newValue+P.units+'"');
	
	eval(this.changeProp + "=P");
	if(newValue!=P.endValue)setTimeout("cjyjs.effect.changeProperties("+this.changeProp+")",20);
	else if(!P.hasOwnProperty("jsEx"))eval(P.jsEx);
}

cjyjs.effect.initUlList=function(P){
	P.obj=$("#"+P.id);
	var liList=P.obj.getElementsByTagName("li");
	for(var i=0;i<liList.length;i++){
		if(liList[i].getElementsByTagName("li").length>0)continue;
		if(i%2==1)$(liList[i]).addClass("alternate");
		liList[i].index=i;
		liList[i].onmouseover=function(){
			var t=$(this);
			t.removeClass("normalA1");
			t.addClass("activeA1");
			if(t.index%2==1)t.removeClass("alternate");
		}
		liList[i].onmouseout=function(){
			var t=$(this);
			t.removeClass("activeA1");
			t.addClass("normalA1");
			if(t.index%2==1)t.addClass("alternate");
		}
	}
}
cjyjs.effect.initTableList=function(P){
	P.obj=$("#"+P.id);
	var liList=P.obj.getElementsByTagName("tr");
	for(var i=0;i<liList.length;i++){
		//if(liList[i].getElementsByTagName("tr").length>0)continue;
		if(i%2==1)$(liList[i]).addClass("alternate");
		liList[i].index=i;
		liList[i].onmouseover=function(){
			var t=$(this);
			t.removeClass("normalA1");
			t.addClass("activeA1");
			if(t.index%2==1)t.removeClass("alternate");
		}
		liList[i].onmouseout=function(){
			var t=$(this);
			t.removeClass("activeA1");
			t.addClass("normalA1");
			if(t.index%2==1)t.addClass("alternate");
		}
	}
	var tdList=P.obj.getElementsByTagName("td");
	for(var i=0;i<tdList.length;i++){
		if(tdList[i].innerHTML=="")tdList[i].innerHTML="&nbsp;";
	}
}